<?php

(defined('BASEPATH')) or exit('No direct script access allowed');

/* load the HMVC_Router class */
require APPPATH . 'third_party/HMVC/Router.php';

class CMS_Router extends HMVC_Router {

    function __construct() {
        parent::__construct();
    }

    function _parse_routes() {
        // Apply the current module's routing config
        require_once BASEPATH . 'helpers/directory_helper.php';
        $rota = directory_map(APPPATH . 'modules/', true, false);
        foreach ($rota as $location) {
            if (is_file($file = APPPATH . 'modules/' . $location . '/config/routes.php')) {
                include ($file);

                $route = (!isset($route) or !is_array($route)) ? array() : $route;
                $this->routes = array_merge($this->routes, $route);
                unset($route);
            }
        }
        return parent::_parse_routes();
    }

}